check iterable python

37

hasattr(myObj, '__iter__')
try:
    iterator = iter(the_element)
except TypeError:
    # not iterable
else:
    # iterable

# for obj in iterator:
#     pass

Comments

Submit
0 Comments